package service;

import dao.ArticleDAO;
import dao.AuthorDAO;
import data.Article;
import data.Author;
import data.User;
import utils.DAOFactory;

public class AuthorService
{
	private static final AuthorDAO dao_author = (AuthorDAO) DAOFactory.getDAOInstance(DAOFactory.DAOClassName.AUTHOR);
	private static final ArticleDAO dao_article = (ArticleDAO) DAOFactory.getDAOInstance(DAOFactory.DAOClassName.ARTICLE);
	
	public boolean isAuthor(User user){return this.isAuthor(user.getID());}
	public boolean isAuthor(int user_id){return AuthorService.dao_author.isAuthor(user_id);}
	public boolean isAuthor(String username){return AuthorService.dao_author.isAuthor(username);}
	
	
	public Author getAuthor(int user_id){return AuthorService.dao_author.selectByID(user_id);}
	public Author getAuthor(String username){return AuthorService.dao_author.selectByUsername(username);}
	public int getID(String username){return this.getAuthor(username).getID();}
	public String getPenName(int user_id){return this.getAuthor(user_id).getPenName();}
	public String getPenName(String username){return this.getAuthor(username).getPenName();}
	
	
	public void register(User user, String pen_name){this.register(user.getID(), pen_name);}
	public void register(int user_id, String pen_name){AuthorService.dao_author.insert(user_id, pen_name);}
	
	
	public void publishArticle(Article article)
	{
		
	}
}





